# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Daniel Seymour <dannyseeless@gmail.com>

pkgname=emby-server
pkgver=4.7.11.0
_ffmpeg_ver=2022_05_07
_skiasharp_ver=2.80.2
pkgrel=1
pkgdesc='Bring together your videos, music, photos, and live television'
arch=(loong64 x86_64)
url=https://emby.media
license=(custom)
depends=(
  alsa-lib
  aom
  aribb24
  aspnet-runtime-6.0
  bzip2
  dotnet-runtime-6.0
  expat
  ffmpeg
  fontconfig
  fribidi
  glibc
  gmp
  gnutls
  lame
  libass.so
  libchromaprint.so
  libdav1d.so
  libdrm
  libfreetype.so
  libjpeg-turbo
  libmfx
  libpng
  libtesseract.so
  libtheora
  libva-drm.so
  libva.so
  libvorbisenc.so
  libvorbis.so
  libwebp
  libx264.so
  libx265.so
  opus
  sqlite
  zlib
  zvbi
)
makedepends=(
  ffnvcodec-headers
  nasm
)
optdepends=(
  'intel-media-sdk: Intel QuickSync support (requires Emby Premiere)'
  'nvidia-utils: Nvidia NVDEC/NVENC support (requires Emby Premiere)'
)
source=(
  https://github.com/MediaBrowser/Emby.Releases/releases/download/${pkgver}/embyserver-netcore_${pkgver}.zip
  https://mediabrowser.github.io/embytools/ffmpeg-${_ffmpeg_ver}.tar.gz
  https://mediabrowser.github.io/embytools/ffdetect-${_ffmpeg_ver}-x64.tar.xz
  https://mediabrowser.github.io/embytools/libskiasharp-${_skiasharp_ver}-x64.tar.xz
  emby-server
  emby-server.conf
  emby-server.service
  license.docx
  Permission_to_distribute.mbox
)
noextract=(license.docx)
backup=(etc/conf.d/emby-server)
install=emby-server.install
b2sums=('700b1bcfe2f603ae1a5a16c1aa3dbc787d4a0d732734ad8f66443054a0718c64c6e4b1b83b508667409b9dab180ebb0e491e80a4603cd26d4a3af1f573aea77d'
        '0cf98666f22cb08bc02c5a93eb3d73e50648468da8d73edbd1814d2b3ca599532e75f3b597ff770c40712c04a4d1af5ab66b6bb6779b35508dd9e007e66e575d'
        '39dbe0033cf43c77c92ae7e1e6709ae1cb447e8d9654b8b1422658d86994db6e2d04f65311e5f1a9a078bdf533344c37f0ab8e07138bb1eabe7108d87a79c2a0'
        '08ea6a632c7366fb4086d3f42c602e85603bc416ec7e0ea1e7d41814441889fc4858db0128a4e433965ca2d7427f43028864d936b40244b3896fa78102ac38c6'
        '48c11601d00121e725951fd48ba34137804d4a67aa12528a29ca4d43d301d19311182421e96bef7b7ddbc4929dc9d5b577b1659cb0b716b1c1f6938283465c46'
        '49c2e6a27f36a2e44a6b988573ee7d08bacb036008f5360ad1cb617b3d1577bdcd48a323ebb882e0f9ec4483962a96d8bd9af44385feb5245b49dfc191d73352'
        '11cc26f44f81823bcd50ee16344aff94eb0a64d740a2e489d832bc8d48d11f3065bf683da243409bab8e3d8a201083596a27983cc11a90688128442e0116430c'
        'e490c2ec7aff3deb9874a80345273c2aa435624b914a13fe8cba8f07ee44938699a024d0c6784fe68820d3a848cccf5af3f7120c7906356ed17d306fc31b6490'
        '61ca54af95278f498b21b424b4d4bae98660b4b7898bfd9752fe21da20d7c508502014bc1970a60920f3064ca20b31b46ba2a788b3b1371f75b5278add70ffc4')

prepare() {
  rm -rf system/{electron,runtimes/{osx,tizen*,win*}}
}

build() {
  cd ffmpeg-${_ffmpeg_ver}_public
  ./configure \
    --disable-doc \
    --disable-ffplay \
    --disable-shared \
    --disable-vdpau \
    --disable-libxcb \
    --disable-lzma \
    --disable-sdl2 \
    --disable-xlib \
    --enable-chromaprint \
    --enable-fontconfig \
    --enable-gmp \
    --enable-gnutls \
    --enable-gpl \
    --enable-libaom \
    --enable-libaribb24 \
    --enable-libass \
    --enable-libdav1d \
    --enable-libdrm \
    --enable-libfreetype \
    --enable-libfribidi \
    --enable-libmfx \
    --enable-libmp3lame \
    --enable-libopus \
    --enable-libtesseract \
    --enable-libtheora \
    --enable-libvorbis \
    --enable-libwebp \
    --enable-libx264 \
    --enable-libx265 \
    --enable-libzvbi \
    --enable-lto \
    --enable-nvdec \
    --enable-nvenc \
    --enable-static \
    --enable-vaapi \
    --enable-version3
  make
}

package() {
  install -dm 755 "${pkgdir}"/usr/lib
  cp -dr --no-preserve='ownership' system "${pkgdir}"/usr/lib/emby-server
  install -Dm 755 emby-server -t "${pkgdir}"/usr/bin/
  install -Dm 755 bin/ffdetect "${pkgdir}"/usr/bin/ffdetect-emby
  install -Dm 755 ffmpeg-${_ffmpeg_ver}_public/ffmpeg "${pkgdir}"/usr/bin/ffmpeg-emby
  install -Dm 755 ffmpeg-${_ffmpeg_ver}_public/ffprobe "${pkgdir}"/usr/bin/ffprobe-emby
  install -Dm 755 lib/libSkiaSharp.so* -t "${pkgdir}"/usr/lib/emby-server/
  install -Dm 644 emby-server.service -t "${pkgdir}"/usr/lib/systemd/system/
  install -Dm 644 emby-server.conf "${pkgdir}"/etc/conf.d/emby-server
  install -Dm 644 license.docx -t "${pkgdir}"/usr/share/licenses/emby-server/
}

# vim: ts=2 sw=2 et:
